$(function () {

    getIncomeInfoList(1);
    
    $("body").on("click","#settlement-list",function () {
        window.location.href = baseloaction + "/mobile/uc/agent/settlement/initAllSettlementListView";
    }).on("click", "#to-settlement",function () {
        var that =$(this);
        var _class = that.attr("class");
        //如果结算按钮不是灰色，可以继续点击
        if(_class.indexOf("disabled") == -1){
            $.ajax({
                url:baseloaction +'/mobile/uc/agent/settlement/confirmSettlement',
                type:'post',
                dataType:'json',
                success:function (result) {
                    if(result.success==true){
                        that.addClass("disabled");
                        $.alert('<span style="font-size:10px;">结算收益已成功提现至“我的账户”中</br>本次结算的收益为：￥'+result.entity.amount+'</br>本次结算的周期为：'+result.entity.cycleNum+'期<span>',"结算收益提示", function () {
                        });
                    }else{
                        $.toast(result.message);
                    }
                },
                error:function (error) {
                    $.toast('系统错误，结算收益失败');
                }
            });
        }
    });

    /**
     * 查询收益明细列表
     * @param pageNo
     */
    function getIncomeInfoList(pageNo) {
        var params = {};
        params = JSON.stringify(params);
        loadMobilePathData({
            url: baseloaction + '/mobile/uc/agent/income/getIncomeInfoList',
            contextId: 'incomeInfo-list-box',
            pageNo: pageNo,
            params: params,
            pageCall: getIncomeInfoList,
            callback: function (pageNo) {

            }
        })
    }
})